﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Text;

namespace IHISCETeim.Web.MachineSys.JSDWF
{
    public partial class JSDWFFolderEdit : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.修改};
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "JSDWFFolderList";
            }


        }

        protected int FolderID
        {
            get
            {
                return GetRequestValue<int>("FolderID", 0);
            }
        }
        protected JSDWFFolderInfo _folderObj = null;
        protected JSDWFFolderInfo folderObj
        {
            get
            {            
                if (_folderObj == null)
                    _folderObj = JSDWFFolderController.GetByFolderID(FolderID);

                return _folderObj;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "edit")
            {
                addmenu();
            }
        }
        private void addmenu()
        {
            JSDWFFolderInfo obj = Request.SerializableObject<JSDWFFolderInfo>();
            // obj.AgentName = GetRequestValue<string>("dwz.orgLookup.AgentName", "");

            // obj.UserName = GetRequestValue<string>("dwz_orgLookup.UserName", "");
            int r = JSDWFFolderController.Update(obj);

            AddLog(Permission.修改, obj);

            if (r > 0)
                SuccessJson("成功修改", this.DWZRef);
            else
            {
                if (r == -1)
                {
                    ErrorJson("目录[" + obj.FolderName + "]已存在，请重新输入目录名称", this.DWZRef);
                }
                else
                    ErrorJson("修改失败", this.DWZRef);
            }
        }
    }
}